import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import  Quick.UIComponent.MenuBar.Simple 0.1 as Simple


Page{
    id:root
    title: "Menu"


    header: control


    Loader{
        id:control
        sourceComponent: _simp
    }

    Component{
        id:_simp
        Simple.MenuBar{
            MenuBarItem{
                menu: Menu {
                    title: qsTr("Text")
                    Action { text: qsTr("New...") }
                    Action { text: qsTr("Open...") }
                }
                highlighted: true
            }
            Menu {
                title: qsTr("File")
                Action { text: qsTr("New...") }
                Action { text: qsTr("Open...") }
                Action { text: qsTr("Save") }
                Action { text: qsTr("Save &As...") }
                MenuSeparator { }
                Action { text: qsTr("Quit") }
            }
            Menu {
                title: qsTr("Edit")
                Action { text: qsTr("Cu&t") }
                Action { text: qsTr("Copy") }
                Action { text: qsTr("Paste") }
            }
            Menu {
                title: qsTr("Help")
                Action { text: qsTr("&About") }
                MenuItem {
                    text: "Test"
                    onTriggered: document.reset()
                }
            }


        }
    }

    Component{
        id:_sys
        MenuBar {
            MenuBarItem{
                menu: Menu {
                    title: qsTr("Text")
                    Action { text: qsTr("New...") }
                    Action { text: qsTr("Open...") }
                }
                highlighted: true
            }
            Menu {
                title: qsTr("&File")
                Action { text: qsTr("&New...") }
                Action { text: qsTr("&Open...") }
                Action { text: qsTr("&Save") }
                Action { text: qsTr("Save &As...") }
                MenuSeparator { }
                Action { text: qsTr("&Quit") }
            }
            Menu {
                title: qsTr("&Edit")
                Action { text: qsTr("Cu&t") }
                Action { text: qsTr("&Copy") }
                Action { text: qsTr("&Paste") }
            }
            Menu {
                title: qsTr("&Help")
                Action { text: qsTr("&About") }
                MenuItem {
                    text: "Test"
                    onTriggered: document.reset()
                }
            }

        }
    }




    Label{
        id: lbl;
        text: "未点击";
        font.bold: true;
        font.pixelSize: 28;
        anchors.centerIn: parent;
    }

    Row{
        y:100
        spacing: 40

        DelayButton{
            id: delayBtn;
            text: "PressAndHold";

            onActivated: {
                lbl.text = "已点击";
            }
        }


        Dial {
            id: dial
            //Keys.onLeftPressed: {}
            snapMode: Dial.SnapAlways;
            stepSize: 0.1;
            onMoved: {
                lbl.text = value;
            }
        }

        Button{
            id: btnIncrease
            text: "增加"
            onClicked: {
                dial.increase();
            }
        }

        Button{
            id: btnDecrease
            text: "减少"
            onClicked: {
                dial.decrease();
            }
        }

    }


    Action {
        id: system
        text: qsTr("normal")
        icon.source: "qrc:/image/icons/error.svg"
        onTriggered: control.sourceComponent = _sys
    }

    Action {
        id: custom
        text: qsTr("simple")
        icon.source: "qrc:/image/icons/error.svg"
        onTriggered: control.sourceComponent = _simp
    }

    footer:ToolBar {
        Row {
            anchors.fill: parent
            spacing: 10
            ToolButton { action: system }
            ToolButton { action: custom }
        }
    }


}
